home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / X11 / xpm.h < prev    next >
C/C++ Source or Header  |  2006-04-12  |  16KB  |  479 lines

  1. /*
  2.  * Copyright (C) 1989-95 GROUPE BULL
  3.  *
  4.  * Permission is hereby granted, free of charge, to any person obtaining a copy
  5.  * of this software and associated documentation files (the "Software"), to
  6.  * deal in the Software without restriction, including without limitation the
  7.  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8.  * sell copies of the Software, and to permit persons to whom the Software is
  9.  * furnished to do so, subject to the following conditions:
  10.  *
  11.  * The above copyright notice and this permission notice shall be included in
  12.  * all copies or substantial portions of the Software.
  13.  *
  14.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17.  * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  18.  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19.  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20.  *
  21.  * Except as contained in this notice, the name of GROUPE BULL shall not be
  22.  * used in advertising or otherwise to promote the sale, use or other dealings
  23.  * in this Software without prior written authorization from GROUPE BULL.
  24.  */
  25. /* $XFree86: xc/extras/Xpm/lib/xpm.h,v 1.2 2001/08/22 23:36:44 dawes Exp $ */
  26.  
  27. /*****************************************************************************\
  28. * xpm.h:                                                                      *
  29. *                                                                             *
  30. *  XPM library                                                                *
  31. *  Include file                                                               *
  32. *                                                                             *
  33. *  Developed by Arnaud Le Hors                                                *
  34. \*****************************************************************************/
  35.  
  36. /*
  37.  * The code related to FOR_MSW has been added by
  38.  * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
  39.  */
  40.  
  41. /*
  42.  * The code related to AMIGA has been added by
  43.  * Lorens Younes (d93-hyo@nada.kth.se) 4/96
  44.  */
  45.  
  46. #ifndef XPM_h
  47. #define XPM_h
  48.  
  49. /*
  50.  * first some identification numbers:
  51.  * the version and revision numbers are determined with the following rule:
  52.  * SO Major number = LIB minor version number.
  53.  * SO Minor number = LIB sub-minor version number.
  54.  * e.g: Xpm version 3.2f
  55.  *      we forget the 3 which is the format number, 2 gives 2, and f gives 6.
  56.  *      thus we have XpmVersion = 2 and XpmRevision = 6
  57.  *      which gives  SOXPMLIBREV = 2.6
  58.  *
  59.  * Then the XpmIncludeVersion number is built from these numbers.
  60.  */
  61. #define XpmFormat 3
  62. #define XpmVersion 4
  63. #define XpmRevision 11
  64. #define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision)
  65.  
  66. #ifndef XPM_NUMBERS
  67.  
  68. #ifdef FOR_MSW
  69. # define SYSV            /* uses memcpy string.h etc. */
  70. # include <malloc.h>
  71. # include "simx.h"        /* defines some X stuff using MSW types */
  72. #define NEED_STRCASECMP        /* at least for MSVC++ */
  73. #else /* FOR_MSW */
  74. # ifdef AMIGA
  75. #  include "amigax.h"
  76. # else /* not AMIGA */
  77. #  include <X11/Xlib.h>
  78. #  include <X11/Xutil.h>
  79. # endif /* not AMIGA */
  80. #endif /* FOR_MSW */
  81.  
  82. /* let's define Pixel if it is not done yet */
  83. #if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
  84. typedef unsigned long Pixel;    /* Index into colormap */
  85. # define PIXEL_ALREADY_TYPEDEFED
  86. #endif
  87.  
  88. /* Return ErrorStatus codes:
  89.  * null     if full success
  90.  * positive if partial success
  91.  * negative if failure
  92.  */
  93.  
  94. #define XpmColorError    1
  95. #define XpmSuccess       0
  96. #define XpmOpenFailed   -1
  97. #define XpmFileInvalid  -2
  98. #define XpmNoMemory     -3
  99. #define XpmColorFailed  -4
  100.  
  101. typedef struct {
  102.     char *name;            /* Symbolic color name */
  103.     char *value;        /* Color value */
  104.     Pixel pixel;        /* Color pixel */
  105. }      XpmColorSymbol;
  106.  
  107. typedef struct {
  108.     char *name;            /* name of the extension */
  109.     unsigned int nlines;    /* number of lines in this extension */
  110.     char **lines;        /* pointer to the extension array of strings */
  111. }      XpmExtension;
  112.  
  113. typedef struct {
  114.     char *string;        /* characters string */
  115.     char *symbolic;        /* symbolic name */
  116.     char *m_color;        /* monochrom default */
  117.     char *g4_color;        /* 4 level grayscale default */
  118.     char *g_color;        /* other level grayscale default */
  119.     char *c_color;        /* color default */
  120. }      XpmColor;
  121.  
  122. typedef struct {
  123.     unsigned int width;        /* image width */
  124.     unsigned int height;    /* image height */
  125.     unsigned int cpp;        /* number of characters per pixel */
  126.     unsigned int ncolors;    /* number of colors */
  127.     XpmColor *colorTable;    /* list of related colors */
  128.     unsigned int *data;        /* image data */
  129. }      XpmImage;
  130.  
  131. typedef struct {
  132.     unsigned long valuemask;    /* Specifies which attributes are defined */
  133.     char *hints_cmt;        /* Comment of the hints section */
  134.     char *colors_cmt;        /* Comment of the colors section */
  135.     char *pixels_cmt;        /* Comment of the pixels section */
  136.     unsigned int x_hotspot;    /* Returns the x hotspot's coordinate */
  137.     unsigned int y_hotspot;    /* Returns the y hotspot's coordinate */
  138.     unsigned int nextensions;    /* number of extensions */
  139.     XpmExtension *extensions;    /* pointer to array of extensions */
  140. }      XpmInfo;
  141.  
  142. typedef int (*XpmAllocColorFunc)(
  143.     Display*            /* display */,
  144.     Colormap            /* colormap */,
  145.     char*            /* colorname */,
  146.     XColor*            /* xcolor */,
  147.     void*            /* closure */
  148. );
  149.  
  150. typedef int (*XpmFreeColorsFunc)(
  151.     Display*            /* display */,
  152.     Colormap            /* colormap */,
  153.     Pixel*            /* pixels */,
  154.     int                /* npixels */,
  155.     void*            /* closure */
  156. );
  157.  
  158. typedef struct {
  159.     unsigned long valuemask;        /* Specifies which attributes are
  160.                        defined */
  161.  
  162.     Visual *visual;            /* Specifies the visual to use */
  163.     Colormap colormap;            /* Specifies the colormap to use */
  164.     unsigned int depth;            /* Specifies the depth */
  165.     unsigned int width;            /* Returns the width of the created
  166.                        pixmap */
  167.     unsigned int height;        /* Returns the height of the created
  168.                        pixmap */
  169.     unsigned int x_hotspot;        /* Returns the x hotspot's
  170.                        coordinate */
  171.     unsigned int y_hotspot;        /* Returns the y hotspot's
  172.                        coordinate */
  173.     unsigned int cpp;            /* Specifies the number of char per
  174.                        pixel */
  175.     Pixel *pixels;            /* List of used color pixels */
  176.     unsigned int npixels;        /* Number of used pixels */
  177.     XpmColorSymbol *colorsymbols;    /* List of color symbols to override */
  178.     unsigned int numsymbols;        /* Number of symbols */
  179.     char *rgb_fname;            /* RGB text file name */
  180.     unsigned int nextensions;        /* Number of extensions */
  181.     XpmExtension *extensions;        /* List of extensions */
  182.  
  183.     unsigned int ncolors;               /* Number of colors */
  184.     XpmColor *colorTable;               /* List of colors */
  185. /* 3.2 backward compatibility code */
  186.     char *hints_cmt;                    /* Comment of the hints section */
  187.     char *colors_cmt;                   /* Comment of the colors section */
  188.     char *pixels_cmt;                   /* Comment of the pixels section */
  189. /* end 3.2 bc */
  190.     unsigned int mask_pixel;            /* Color table index of transparent
  191.                                            color */
  192.  
  193.     /* Color Allocation Directives */
  194.     Bool exactColors;            /* Only use exact colors for visual */
  195.     unsigned int closeness;        /* Allowable RGB deviation */
  196.     unsigned int red_closeness;        /* Allowable red deviation */
  197.     unsigned int green_closeness;    /* Allowable green deviation */
  198.     unsigned int blue_closeness;    /* Allowable blue deviation */
  199.     int color_key;            /* Use colors from this color set */
  200.  
  201.     Pixel *alloc_pixels;        /* Returns the list of alloc'ed color
  202.                        pixels */
  203.     int nalloc_pixels;            /* Returns the number of alloc'ed
  204.                        color pixels */
  205.  
  206.     Bool alloc_close_colors;        /* Specify whether close colors should
  207.                        be allocated using XAllocColor
  208.                        or not */
  209.     int bitmap_format;            /* Specify the format of 1bit depth
  210.                        images: ZPixmap or XYBitmap */
  211.  
  212.     /* Color functions */
  213.     XpmAllocColorFunc alloc_color;    /* Application color allocator */
  214.     XpmFreeColorsFunc free_colors;    /* Application color de-allocator */
  215.     void *color_closure;        /* Application private data to pass to
  216.                        alloc_color and free_colors */
  217.  
  218. }      XpmAttributes;
  219.  
  220. /* XpmAttributes value masks bits */
  221. #define XpmVisual       (1L<<0)
  222. #define XpmColormap       (1L<<1)
  223. #define XpmDepth       (1L<<2)
  224. #define XpmSize           (1L<<3)    /* width & height */
  225. #define XpmHotspot       (1L<<4)    /* x_hotspot & y_hotspot */
  226. #define XpmCharsPerPixel   (1L<<5)
  227. #define XpmColorSymbols       (1L<<6)
  228. #define XpmRgbFilename       (1L<<7)
  229. /* 3.2 backward compatibility code */
  230. #define XpmInfos       (1L<<8)
  231. #define XpmReturnInfos       XpmInfos
  232. /* end 3.2 bc */
  233. #define XpmReturnPixels       (1L<<9)
  234. #define XpmExtensions      (1L<<10)
  235. #define XpmReturnExtensions XpmExtensions
  236.  
  237. #define XpmExactColors     (1L<<11)
  238. #define XpmCloseness       (1L<<12)
  239. #define XpmRGBCloseness       (1L<<13)
  240. #define XpmColorKey       (1L<<14)
  241.  
  242. #define XpmColorTable      (1L<<15)
  243. #define XpmReturnColorTable XpmColorTable
  244.  
  245. #define XpmReturnAllocPixels (1L<<16)
  246. #define XpmAllocCloseColors (1L<<17)
  247. #define XpmBitmapFormat    (1L<<18)
  248.  
  249. #define XpmAllocColor      (1L<<19)
  250. #define XpmFreeColors      (1L<<20)
  251. #define XpmColorClosure    (1L<<21)
  252.  
  253.  
  254. /* XpmInfo value masks bits */
  255. #define XpmComments        XpmInfos
  256. #define XpmReturnComments  XpmComments
  257.  
  258. /* XpmAttributes mask_pixel value when there is no mask */
  259. #ifndef FOR_MSW
  260. #define XpmUndefPixel 0x80000000
  261. #else
  262. /* int is only 16 bit for MSW */
  263. #define XpmUndefPixel 0x8000
  264. #endif
  265.  
  266. /*
  267.  * color keys for visual type, they must fit along with the number key of
  268.  * each related element in xpmColorKeys[] defined in XpmI.h
  269.  */
  270. #define XPM_MONO    2
  271. #define XPM_GREY4    3
  272. #define XPM_GRAY4    3
  273. #define XPM_GREY     4
  274. #define XPM_GRAY     4
  275. #define XPM_COLOR    5
  276.  
  277.  
  278. /* macros for forward declarations of functions with prototypes */
  279. #define FUNC(f, t, p) extern t f p
  280. #define LFUNC(f, t, p) static t f p
  281.  
  282.  
  283. /*
  284.  * functions declarations
  285.  */
  286.  
  287. _XFUNCPROTOBEGIN
  288.  
  289. /* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
  290. /* Same for Amiga! */
  291.  
  292. #if !defined(FOR_MSW) && !defined(AMIGA)
  293.     FUNC(XpmCreatePixmapFromData, int, (Display *display,
  294.                     Drawable d,
  295.                     char **data,
  296.                     Pixmap *pixmap_return,
  297.                     Pixmap *shapemask_return,
  298.                     XpmAttributes *attributes));
  299.  
  300.     FUNC(XpmCreateDataFromPixmap, int, (Display *display,
  301.                     char ***data_return,
  302.                     Pixmap pixmap,
  303.                     Pixmap shapemask,
  304.                     XpmAttributes *attributes));
  305.  
  306.     FUNC(XpmReadFileToPixmap, int, (Display *display,
  307.                     Drawable d,
  308.                     char *filename,
  309.                     Pixmap *pixmap_return,
  310.                     Pixmap *shapemask_return,
  311.                     XpmAttributes *attributes));
  312.  
  313.     FUNC(XpmWriteFileFromPixmap, int, (Display *display,
  314.                        char *filename,
  315.                        Pixmap pixmap,
  316.                        Pixmap shapemask,
  317.                        XpmAttributes *attributes));
  318. #endif
  319.  
  320.     FUNC(XpmCreateImageFromData, int, (Display *display,
  321.                        char **data,
  322.                        XImage **image_return,
  323.                        XImage **shapemask_return,
  324.                        XpmAttributes *attributes));
  325.  
  326.     FUNC(XpmCreateDataFromImage, int, (Display *display,
  327.                        char ***data_return,
  328.                        XImage *image,
  329.                        XImage *shapeimage,
  330.                        XpmAttributes *attributes));
  331.  
  332.     FUNC(XpmReadFileToImage, int, (Display *display,
  333.                    char *filename,
  334.                    XImage **image_return,
  335.                    XImage **shapeimage_return,
  336.                    XpmAttributes *attributes));
  337.  
  338.     FUNC(XpmWriteFileFromImage, int, (Display *display,
  339.                       char *filename,
  340.                       XImage *image,
  341.                       XImage *shapeimage,
  342.                       XpmAttributes *attributes));
  343.  
  344.     FUNC(XpmCreateImageFromBuffer, int, (Display *display,
  345.                      char *buffer,
  346.                      XImage **image_return,
  347.                      XImage **shapemask_return,
  348.                      XpmAttributes *attributes));
  349. #if !defined(FOR_MSW) && !defined(AMIGA)
  350.     FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
  351.                       Drawable d,
  352.                       char *buffer,
  353.                       Pixmap *pixmap_return,
  354.                       Pixmap *shapemask_return,
  355.                       XpmAttributes *attributes));
  356.  
  357.     FUNC(XpmCreateBufferFromImage, int, (Display *display,
  358.                      char **buffer_return,
  359.                      XImage *image,
  360.                      XImage *shapeimage,
  361.                      XpmAttributes *attributes));
  362.  
  363.     FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
  364.                       char **buffer_return,
  365.                       Pixmap pixmap,
  366.                       Pixmap shapemask,
  367.                       XpmAttributes *attributes));
  368. #endif
  369.     FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
  370.     FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
  371.  
  372.     FUNC(XpmReadFileToData, int, (char *filename, char ***data_return));
  373.     FUNC(XpmWriteFileFromData, int, (char *filename, char **data));
  374.  
  375.     FUNC(XpmAttributesSize, int, (void));
  376.     FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
  377.     FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
  378.                    int nextensions));
  379.  
  380.     FUNC(XpmFreeXpmImage, void, (XpmImage *image));
  381.     FUNC(XpmFreeXpmInfo, void, (XpmInfo *info));
  382.     FUNC(XpmGetErrorString, char *, (int errcode));
  383.     FUNC(XpmLibraryVersion, int, (void));
  384.  
  385.     /* XpmImage functions */
  386.     FUNC(XpmReadFileToXpmImage, int, (char *filename,
  387.                       XpmImage *image,
  388.                       XpmInfo *info));
  389.  
  390.     FUNC(XpmWriteFileFromXpmImage, int, (char *filename,
  391.                      XpmImage *image,
  392.                      XpmInfo *info));
  393. #if !defined(FOR_MSW) && !defined(AMIGA)
  394.     FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
  395.                         Drawable d,
  396.                         XpmImage *image,
  397.                         Pixmap *pixmap_return,
  398.                         Pixmap *shapemask_return,
  399.                         XpmAttributes *attributes));
  400. #endif
  401.     FUNC(XpmCreateImageFromXpmImage, int, (Display *display,
  402.                        XpmImage *image,
  403.                        XImage **image_return,
  404.                        XImage **shapeimage_return,
  405.                        XpmAttributes *attributes));
  406.  
  407.     FUNC(XpmCreateXpmImageFromImage, int, (Display *display,
  408.                        XImage *image,
  409.                        XImage *shapeimage,
  410.                        XpmImage *xpmimage,
  411.                        XpmAttributes *attributes));
  412. #if !defined(FOR_MSW) && !defined(AMIGA)
  413.     FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
  414.                         Pixmap pixmap,
  415.                         Pixmap shapemask,
  416.                         XpmImage *xpmimage,
  417.                         XpmAttributes *attributes));
  418. #endif
  419.     FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return,
  420.                       XpmImage *image,
  421.                       XpmInfo *info));
  422.  
  423.     FUNC(XpmCreateXpmImageFromData, int, (char **data,
  424.                       XpmImage *image,
  425.                       XpmInfo *info));
  426.  
  427.     FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer,
  428.                         XpmImage *image,
  429.                         XpmInfo *info));
  430.  
  431.     FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return,
  432.                         XpmImage *image,
  433.                         XpmInfo *info));
  434.  
  435.     FUNC(XpmGetParseError, int, (char *filename,
  436.                  int *linenum_return,
  437.                  int *charnum_return));
  438.  
  439.     FUNC(XpmFree, void, (void *ptr));
  440.  
  441. _XFUNCPROTOEND
  442.  
  443. /* backward compatibility */
  444.  
  445. /* for version 3.0c */
  446. #define XpmPixmapColorError  XpmColorError
  447. #define XpmPixmapSuccess     XpmSuccess
  448. #define XpmPixmapOpenFailed  XpmOpenFailed
  449. #define XpmPixmapFileInvalid XpmFileInvalid
  450. #define XpmPixmapNoMemory    XpmNoMemory
  451. #define XpmPixmapColorFailed XpmColorFailed
  452.  
  453. #define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
  454.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  455. #define XpmWritePixmapFile(dpy, file, pix, mask, att) \
  456.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  457.  
  458. /* for version 3.0b */
  459. #define PixmapColorError  XpmColorError
  460. #define PixmapSuccess     XpmSuccess
  461. #define PixmapOpenFailed  XpmOpenFailed
  462. #define PixmapFileInvalid XpmFileInvalid
  463. #define PixmapNoMemory    XpmNoMemory
  464. #define PixmapColorFailed XpmColorFailed
  465.  
  466. #define ColorSymbol XpmColorSymbol
  467.  
  468. #define XReadPixmapFile(dpy, d, file, pix, mask, att) \
  469.     XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
  470. #define XWritePixmapFile(dpy, file, pix, mask, att) \
  471.     XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
  472. #define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
  473.     XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
  474. #define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
  475.     XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
  476.  
  477. #endif /* XPM_NUMBERS */
  478. #endif
  479.